// Set是一种叫做集合的数据结构
// 集合：无序，相关联，不重复
let set = new Set([1,2,3,4]);

console.log(set.keys());
console.log(set.values());
console.log(set.entries());

// 1. 数组去重
let arr = [1,1,2,2,3,3];
let unique = [...new Set(arr)];
console.log(unique);


let a = new Set([1,2,3]);
let b = new Set([4,2,3]);

// 2.并集
let union = [...new Set([...a,...b])];
console.log(union);

// 3.交集
let intersect = [... new Set([...a].filter(x => b.has(x)))];
console.log(intersect);

// 4.差集
let difference = [...new Set([...a].filter(x=>!b.has(x)))];
console.log(difference);